import http from '../utils/request'

export interface SearchApp {
  page: number;
  pageSize: number;
  APPName: string;
}

export interface App {
  id: string;
  name: string;
  alias: string;
  protocol: string;
  ip: string;
  port: number;
  accountType: number;
  credentialId: string;
  description: string;
  gatewayId: string;
  connectParams: string;
  isDesktop: boolean;
  creator: string;
  creatorId: string;
  createTime: number;
}

interface AppPage {
  list: App[];
  total: number;
}

// 获取应用分页信息
export const getAppPage = (data?: object): Promise<AppPage> => {
  return http.get('/app/page', { params: data })
}

// 添加应用
export const addApp = (data: object) => {
  return http.post('/app/add', { data })
}

// 删除应用
export const deleteApp = (data: object) => {
  return http.delete('/app/delete', { params: data })
}

// ----------------- 主机 ------------------
export interface HostServer {
  id: string;
  hostName: string;
  ip: string;
  communicationPort:number;
  domain:string;
  hostAlias:string;
  status:number;
  addType:number;
}

interface HostPage {
  list: HostServer[];
  total: number;
}

export interface SearchHost {
  page: number;
  pageSize: number;
  hostIp: string;
}

// 获取主机分页信息
export const getHostPage = (data?: object): Promise<HostPage> => {
  return http.get('/host/page', { params: data })
}

// 添加主机
export const addHost = (data: HostServer) => {
  return http.post('/host/add', data)
}

// 删除主机
export const deleteHost = (data: object) => {
  return http.delete('/host/delete', { params: data })
}
